Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • A quetion of coefplot*command

    Dear Statalist,

    I am trying to plot the regression coefficients. My codes are as follows.

    reghdfe rela_parent ib0.meet $s ,absorb(pid year) vce(robust)
    est store Meet
    reghdfe rela_parent ib0.phone $s ,absorb(pid year) vce(robust)
    est store Phone
    reghdfe rela_parent ib0.other $s ,absorb(pid year) vce(robust)
    est store Other

    coefplot (Meet, label("Meet") color("133 135 134") ciopts(color("133 135 134"))) ///
    (Phone, label("Phone") color("225 178 36") ciopts(color("225 178 36"))) ///
    (Other, label("Other") color("135 187 175") ciopts(color("135 187 175"))), ///
    keep(*meet* *phone* *other*) ///
    xline(0, lp(dash) lcolor(gs10)) ///
    ciopts(recast(rcap)) ///
    graphregion(color(white))

    I got a figure as follows.

    Click image for larger version

Name:	_20250314170418.png
Views:	1
Size:	18.6 KB
ID:	1774343



    I want to reshape this graph as follows.

    Click image for larger version

Name:	quicker.png
Views:	1
Size:	399.9 KB
ID:	1774344



    How can I do that using the coefplot command?

    Thank you for your help.




  • #2
    Data example?

    Comment


    • #3
      Originally posted by Andrew Musau View Post
      Data example?
      pid year rela_parent meet phone other
      130463102 2014 0 0 0 0
      130463102 2016 0 0 0 0
      130463103 2016 0 2 0 0
      130463104 2016 0 1 2 2
      130463104 2018 1 1 0 0
      130463551 2016 0 1 2 0
      130463553 2016 0 0 0 0
      130464101 2014 0 0 0 0
      130464101 2016 0 0 0 0
      130464103 2016 1 1 1 1
      130464103 2018 0 1 1 1
      130465101 2014 0 0 0 0
      130465101 2016 0 0 0 0
      130465103 2014 0 0 0 0
      130465103 2016 0 1 2 2
      130465103 2018 1 2 2 0

      rela_parent : binary variable
      meet. phone,and other : four categories, 0.1.2.3

      Thank you!

      Comment


      • #4
        Thanks for the data example. reghdfe is from https://github.com/sergiocorreia/reghdfe and coefplot is from SSC (FAQ Advice #12).

        Code:
        clear
        input double pid float(year rela_parent meet phone other)
        130463102 2014 0 0 0 0
        130463102 2016 0 0 0 0
        130463103 2016 0 2 0 0
        130463104 2016 0 0 2 2
        130463104 2018 1 1 0 0
        130463551 2016 0 1 2 0
        130463553 2016 0 0 0 0
        130464101 2014 0 0 0 0
        130464101 2016 0 0 0 0
        130464103 2016 1 1 1 1
        130464103 2018 0 1 1 1
        130465101 2014 0 0 0 0
        130465101 2016 0 0 0 0
        130465103 2014 0 0 0 0
        130465103 2016 0 1 2 2
        130465103 2018 1 2 2 0
        130463102 2014 0 0 0 0
        130463105 2016 0 0 0 0
        130463106 2016 0 2 0 0
        130463107 2016 0 1 2 2
        130463107 2018 1 0 0 0
        130463558 2016 0 0 2 0
        130463559 2016 0 0 0 0
        130464222 2014 0 0 0 0
        130464222 2016 0 0 0 0
        130464333 2016 1 1 1 1
        130464333 2018 0 1 1 1
        130465444 2014 0 0 0 0
        130465444 2016 0 0 0 0
        130465555 2014 0 0 0 0
        130465555 2016 0 1 2 2
        130465777 2018 1 2 2 0
        end
        
        reghdfe rela_parent ib0.meet,noabsorb vce(robust)
        est store Meet
        reghdfe rela_parent ib0.phone,noabsorb vce(robust)
        est store Phone
        reghdfe rela_parent ib0.other,noabsorb vce(robust)
        est store Other
        
        coefplot (Meet Phone Other, keep(1.*) label("Daily") ///
        color("133 135 134") ciopts(color("133 135 134"))) ///
        (Meet Phone Other, keep(2.*) label("Weekly") ///
        color("225 178 36") ciopts(color("225 178 36"))), aseq ylab("")
        Res.:
        Click image for larger version

Name:	Graph.png
Views:	1
Size:	31.4 KB
ID:	1774377

        Last edited by Andrew Musau; 14 Mar 2025, 11:06.

        Comment


        • #5
          Originally posted by Andrew Musau View Post
          Thanks for the data example. reghdfe is from https://github.com/sergiocorreia/reghdfe and coefplot is from SSC (FAQ Advice #12).

          Code:
          clear
          input double pid float(year rela_parent meet phone other)
          130463102 2014 0 0 0 0
          130463102 2016 0 0 0 0
          130463103 2016 0 2 0 0
          130463104 2016 0 0 2 2
          130463104 2018 1 1 0 0
          130463551 2016 0 1 2 0
          130463553 2016 0 0 0 0
          130464101 2014 0 0 0 0
          130464101 2016 0 0 0 0
          130464103 2016 1 1 1 1
          130464103 2018 0 1 1 1
          130465101 2014 0 0 0 0
          130465101 2016 0 0 0 0
          130465103 2014 0 0 0 0
          130465103 2016 0 1 2 2
          130465103 2018 1 2 2 0
          130463102 2014 0 0 0 0
          130463105 2016 0 0 0 0
          130463106 2016 0 2 0 0
          130463107 2016 0 1 2 2
          130463107 2018 1 0 0 0
          130463558 2016 0 0 2 0
          130463559 2016 0 0 0 0
          130464222 2014 0 0 0 0
          130464222 2016 0 0 0 0
          130464333 2016 1 1 1 1
          130464333 2018 0 1 1 1
          130465444 2014 0 0 0 0
          130465444 2016 0 0 0 0
          130465555 2014 0 0 0 0
          130465555 2016 0 1 2 2
          130465777 2018 1 2 2 0
          end
          
          reghdfe rela_parent ib0.meet,noabsorb vce(robust)
          est store Meet
          reghdfe rela_parent ib0.phone,noabsorb vce(robust)
          est store Phone
          reghdfe rela_parent ib0.other,noabsorb vce(robust)
          est store Other
          
          coefplot (Meet Phone Other, keep(1.*) label("Daily") ///
          color("133 135 134") ciopts(color("133 135 134"))) ///
          (Meet Phone Other, keep(2.*) label("Weekly") ///
          color("225 178 36") ciopts(color("225 178 36"))), aseq ylab("")
          Res.:
          [ATTACH=CONFIG]n1774377[/ATTACH]

          Thank you very much !!!!!

          Comment

          Working...
          X